define(['jquery'], function($) {
	return function() {
		console.log(111111);

		var user = document.getElementById("user");
		var userId = document.getElementById("user_prompt");
		var pwd = document.getElementById("pwd");
		var pwdId = document.getElementById("pwd_prompt");
		var repwd = document.getElementById("repwd");
		var repwdId = document.getElementById("repwd_prompt");
		var email = document.getElementById("email");
		var emailId = document.getElementById("email_prompt");
		var mobile = document.getElementById("mobile");
		var mobileId = document.getElementById("mobile_prompt");
		var yzm = document.getElementById("yzm");
		var yzmId = document.getElementById("yzm_prompt");
		/*用户名验证*/
		user.onblur = function() {
			var nameValue = user.value;
			var reg = /^[a-zA-Z][a-zA-Z0-9]{3,15}$/;
			if(nameValue == "" || nameValue == null) {
				userId.innerHTML = "必须填写";
				$('#user').css("border", "1px solid red");
				$('.regist_item_ifo1').hover(
					function() {
						$('.formError1').css("display", "block");
					},
					function() {
						$('.formError1').css("display", "none");
					}
				)
				return false;
			} else if(reg.test(nameValue) == false) {
				userId.innerHTML = "用户名由英文字母和数字组成的4-16位字符，以字母开头!";
				$('#user').css("border", "1px solid red");
				$('.regist_item_ifo1').hover(
					function() {
						$('.formError1').css("display", "block");
					},
					function() {
						$('.formError1').css("display", "none");
					}
				)
				return false;
			} else {
				$('#user').css("border", "1px solid #e8e8e8");
				$('.regist_item_ifo1').hover(
					function() {
						$('.formError1').css("display", "none");
					},
					function() {
						$('.formError1').css("display", "none");
					}
				)
				return true;
			}

		}

		/*密码验证*/
		pwd.onblur = function() {
			var pwdValue = pwd.value;
			var reg = /^[a-zA-Z0-9]{4,10}$/;
			if(pwdValue == "" || pwdValue == null) {
				pwdId.innerHTML = "必须填写";
				$('#pwd').css("border", "1px solid red");
				$('.regist_item_ifo2').hover(
					function() {
						$('.formError2').css("display", "block");
					},
					function() {
						$('.formError2').css("display", "none");
					}
				)
				return false;
			} else if(reg.test(pwdValue) == false) {
				pwdId.innerHTML = "密码不能含有非法字符，长度在4-10之间!";
				$('#pwd').css("border", "1px solid red");
				$('.regist_item_ifo2').hover(
					function() {
						$('.formError2').css("display", "block");
					},
					function() {
						$('.formError2').css("display", "none");
					}
				)
				return false;
			} else {
				$('#pwd').css("border", "1px solid #e8e8e8");
				$('.regist_item_ifo2').hover(
					function() {
						$('.formError2').css("display", "none");
					},
					function() {
						$('.formError2').css("display", "none");
					}
				)
				return true;
			}
		}

		repwd.onblur = function() {
			var pwdValue = pwd.value;
			var repwdValue = repwd.value;
			if(repwdValue == "" || repwdValue == null) {
				repwdId.innerHTML = "必须填写";
				$('#repwd').css("border", "1px solid red");
				$('.regist_item_ifo3').hover(
					function() {
						$('.formError3').css("display", "block");
					},
					function() {
						$('.formError3').css("display", "none");
					}
				)
				return false;
			} else if(pwdValue != repwdValue) {
				repwdId.innerHTML = "两次输入密码不一致!";
				$('#repwd').css("border", "1px solid red");
				$('.regist_item_ifo3').hover(
					function() {
						$('.formError3').css("display", "block");
					},
					function() {
						$('.formError3').css("display", "none");
					}
				)
				return false;
			} else {
				$('#repwd').css("border", "1px solid #e8e8e8");
				$('.regist_item_ifo3').hover(
					function() {
						$('.formError3').css("display", "none");
					},
					function() {
						$('.formError3').css("display", "none");
					}
				)
				return true;
			}
		}

		/*验证邮箱*/
		$('.regist_item_ifo4').click(function() {
			$('.regist_text').css("display", "block");
		});
		$('#email').blur(function() {
			$('.regist_text').css("display", "none");
		});
		email.onblur = function() {
			var emailValue = email.value;
			var reg = /^\w+@\w+(\.[a-zA-Z]{2,3}){1,2}$/;
			if(reg.test(emailValue) == false) {
				emailId.innerHTML = "请输入有效的邮箱地址！";
				$('#email').css("border", "1px solid red");
				$('.regist_item_ifo4').hover(
					function() {
						$('.formError4').css("display", "block");
					},
					function() {
						$('.formError4').css("display", "none");
					}
				)
				return false;
			} else {
				$('#email').css("border", "1px solid #e8e8e8");
				$('.regist_item_ifo4').hover(
					function() {
						$('.formError4').css("display", "none");
					},
					function() {
						$('.formError4').css("display", "none");
					}
				)
				return true;
			}
		}

		/*验证手机号*/
		mobile.onblur = function() {
			var mobileValue = mobile.value;
			var reg = /^1\d{10}$/;
			if(mobileValue == "" || mobileValue == null) {
				mobileId.innerHTML = "必须填写";
				$('#mobile').css("border", "1px solid red");
				$('.regist_item_ifo5').hover(
					function() {
						$('.formError5').css("display", "block");
					},
					function() {
						$('.formError5').css("display", "none");
					}
				)
				return false;
			} else if(reg.test(mobileValue) == false) {
				mobileId.innerHTML = "请输入正确的手机号码!";
				$('#mobile').css("border", "1px solid red");
				$('.regist_item_ifo5').hover(
					function() {
						$('.formError5').css("display", "block");
					},
					function() {
						$('.formError5').css("display", "none");
					}
				)
				return false;
			} else {
				$('#mobile').css("border", "1px solid #e8e8e8");
				$('.regist_item_ifo5').hover(
					function() {
						$('.formError5').css("display", "none");
					},
					function() {
						$('.formError5').css("display", "none");
					}
				)
				return true;
			}
		}

		/*验证码验证*/
		yzm.onblur = function() {
			var yzmValue = yzm.value;
			var reg = /^\d{4}$/;
			if(yzmValue == "" || yzmValue == null) {
				yzmId.innerHTML = "必须填写";
				$('#yzm').css("border", "1px solid red");
				$('.regist_item_ifo6').hover(
					function() {
						$('.formError6').css("display", "block");
					},
					function() {
						$('.formError6').css("display", "none");
					}
				)
				return false;
			} else if(reg.test(yzmValue) == false) {
				yzmId.innerHTML = "验证码错误!";
				$('#yzm').css("border", "1px solid red");
				$('.regist_item_ifo6').hover(
					function() {
						$('.formError6').css("display", "block");
					},
					function() {
						$('.formError6').css("display", "none");
					}
				)
				return false;
			} else {
				$('#yzm').css("border", "1px solid #e8e8e8");
				$('.regist_item_ifo6').hover(
					function() {
						$('.formError6').css("display", "none");
					},
					function() {
						$('.formError6').css("display", "none");
					}
				)
				return true;
			}

		}
	}
})